package com.wen.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 20212
 * 日期转换工具类
 */
public class DateUtils {

    /**
     * 日期转换成字符串
     */
    public static String date2String(Date date, String patt) {
        SimpleDateFormat sdf = new SimpleDateFormat(patt);
        String format = sdf.format(date);
        return format;
    }

    /**
     * 字符串转成日期
     */
    public static Date string2Date(String str, String patt) {
        SimpleDateFormat sdf = new SimpleDateFormat(patt);
        Date parse = null;
        try {
            parse = sdf.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
}